import pyHook
import pythoncom


# 监听到键盘事件调用
def onKeyboardEvent(event):
    print(event.Key)  # 返回按下的键
    return True


# 创建管理器
hm = pyHook.HookManager()
# 监听键盘
hm.KeyDown = onKeyboardEvent
hm.HookKeyboard()
# 循环监听
pythoncom.PumpMessages()
